import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:getx/common/routes/app_pages.dart';

class RouteAuthMiddleware extends GetMiddleware {
  final int? _priority;

  RouteAuthMiddleware({int? priority}) : _priority = priority;

  @override
  int? get priority => _priority;

  @override
  RouteSettings? redirect(String? route) {
    if (route != null) {
      Future.delayed(const Duration(seconds: 1), () {
        Get.snackbar("提示", "请先登录APP");
      });
      return const RouteSettings(name: AppRoutes.Login);
    }
    return null;
  }
}